//
// Created by lingzhitech on 25-9-24.
//

#include "Utils.hpp"

#include <iostream>
#include <vector>

std::string make_plural(size_t ctr, const std::string &word,
                        const std::string &ending) {
    return (ctr > 1) ? word + ending : word;
}


void elimDups(std::vector<std::string>& words)
{
    //排序
    sort(words.begin(), words.end());
    //算法不会对container的大小造成影响，它的作用对象是iterator，不是container
    auto end_unique = unique(words.begin(), words.end());
    //删除重复元素
    words.erase(end_unique, words.end());
}

bool isShorter(const std::string &s1, const std::string &s2)
{
    return s1.size() < s2.size();
}

bool compareIsbn(const Sales_data &s1, const Sales_data &s2) {
    return s1.isbn() < s2.isbn();
}

bool isOver5Charaters(std::string &s) {
    return s.length() >= 5;
}

bool isOverSize(const std::string &word, std::size_t sz) {
    return word.size() > sz;
}

bool check_size(const std::string &s, std::string::size_type sz)
{
    return s.size() >= sz;
}